package cn.edu.jju.psytest.model.vo;

import java.util.Iterator;
import java.util.Map.Entry;

import cn.edu.jju.psytest.model.constant.UserConstant;

public class QueriedStuTRVo {
	private String sno;
	private String name;
	private String secondaryCollege;
	private String major;
	private String clazz;

	private TestResultVo trVo;

	/**
	 * @return
	 */
	public String toJSONString() {
		Iterator<Entry<String, String>> iterator = trVo
				.getFactorsAverageScore().entrySet().iterator();
		String factorsAverageScoreS = "";
		while (iterator.hasNext()) {
			Entry<String, String> entry = iterator.next();
			factorsAverageScoreS += "\"" + entry.getKey() + "\":\""
					+ entry.getValue() + "\"" + ",";
		}
		factorsAverageScoreS = factorsAverageScoreS.substring(0,
				factorsAverageScoreS.lastIndexOf(","));

		return "{\"sno\":\""
				+ sno
				+ "\","
				+ "\"name\":\""
				+ name
				+ "\","
				+ "\"sc\":\""
				+ UserConstant.secondaryColleges.get(Integer
						.parseInt(secondaryCollege)) + "\"," + "\"major\":\""
				+ major + "\"," + "\"clazz\":\"" + clazz + "\"," + "\"ts\":\""
				+ trVo.getTotalScore() + "\"," + "\"tas\":\""
				+ trVo.getTotalAverageScore() + "\"," + "\"nopi\":\""
				+ trVo.getNumOfPositiveItems() + "\"," + "\"pi\":["
				+ trVo.getPositiveItems() + "]," + "\"noni\":\""
				+ trVo.getNumOfNegativeItems() + "\"," + "\"ni\":["
				+ trVo.getNegativeItems() + "]," + "\"fas\":{"
				+ factorsAverageScoreS + "}}";
	}

	public String getSno() {
		return sno;
	}

	public void setSno(String sno) {
		this.sno = sno;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getSecondaryCollege() {
		return secondaryCollege;
	}

	public void setSecondaryCollege(String secondaryCollege) {
		this.secondaryCollege = secondaryCollege;
	}

	public String getMajor() {
		return major;
	}

	public void setMajor(String major) {
		this.major = major;
	}

	public String getClazz() {
		return clazz;
	}

	public void setClazz(String clazz) {
		this.clazz = clazz;
	}

	public TestResultVo getTrVo() {
		return trVo;
	}

	public void setTrVo(TestResultVo trVo) {
		this.trVo = trVo;
	}
}
